package com.atguigu02.selfdefine.exer2;

import org.junit.Test;

import java.util.Arrays;

/**
 * ClassName: Answer
 * Package: com.atguigu02.selfdefine.exer2
 * Description:
 *
 * @Author BuTang
 * @Create 2023/6/10 15:35
 * @Version 1.0
 */
public class Answer {
    public static <E> void method1( E[] e,int a,int b ){
        E tem  = e[a];
        e[a] = e[b];
        e[b] = tem;

    }
    @Test
    public void test1(){
        String[] s = new String[]{"aa","bb","cc"};
        method1(s,0,2);
        System.out.println(Arrays.toString(s));
    }

    public static <E> void method2( E[] e){
        for (int i = 0; i < e.length/2; i++) {
            E e1 = e[i];
            e[i] = e[e.length-1-i];
            e[e.length-1-i] = e1;
        }
    }

    @Test
    public void test2(){
        Integer[] i = new Integer[]{1,2,3,4,5,6,7,8,9};
        System.out.println(Arrays.toString(i));
        method2(i);
        System.out.println(Arrays.toString(i));

    }
}
